package day0726;

import java.util.Scanner;

//输入：nums = [1,2,3,4,5,6,7,8,9,10]         target = 9
//输出：[0,1]
public class Test1 {
    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,7,8,9,10};
        int target = 13;
        String result=findIndex(nums, target);
        System.out.println(result);
    }
    //从nums中找两个能相加得到18的数，并打印这两个数
    private static String findIndex(int[] nums, int target) {
        for (int i = 0; i <9 ; i++) {
            int left=nums[i];
            for (int j = i+1; j < 10; j++) {
                int right=nums[j];
                if(left + right   ==  target){
                    return left+"所在下标是:"+i+","+right+"所在下标是:"+j;
                }
            }
        }
        return "没找到两个数相加等于"+target+"的数";
    }
}


